package com.yxj.dries.data;

import androidx.room.TypeConverter;

import java.util.Calendar;
import java.util.Date;

public class Converters {

    private static final Calendar cal = Calendar.getInstance();

    @TypeConverter
    public static Long calendarToDateStamp(Calendar calendar) {
        return calendar.getTimeInMillis();
    }

    @TypeConverter
    public static Calendar dateStampToCalendar(Long date) {
        cal.setTimeInMillis(date);
        return cal;
    }

    @TypeConverter
    public static Long date2Long(Date date) {
        return date.getTime();
    }

    @TypeConverter
    public static Date long2Date(Long data) {
        return new Date(data);
    }
}
